package main

import (
	"fmt"
	"log"
	"os"

	"github.com/urfave/cli/v2"
)

func main() {

	app := &cli.App{
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:    "lang",
				Value:   "english",
				Aliases: []string{"l"},
				Usage:   "language for the greeting",
			},
		},

		Name:      "Dxp app",
		UsageText: "Dxp app test",
		Action: func(c *cli.Context) error {
			hello := "中文"
			if c.NArg() > 0 {
				hello = c.Args().Get(0)
			}

			if c.String("lang") == "en" {
				fmt.Println("hello", hello)
			} else {
				fmt.Println("您好", hello)
			}
			return nil
		},
		Commands: []*cli.Command{
			{
				Name:    "compete",
				Aliases: []string{"alia"},
				Usage:   "complelte Usage",
				Action: func(c *cli.Context) error {
					log.Println("com action")
					return nil
				},
			},
		},
	}

	err := app.Run(os.Args)

	if err != nil {
		log.Fatal(err)
	}
}
